/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Business;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author anhvtn_b00545
 */
public class loadPurchase extends  AbstractTableModel{
    private int COLUMNS = 3;
    private List<Purchase_BS> list;

    public loadPurchase(List<Purchase_BS> list) {
        this.list = list;
    }
    
    public int getRowCount() {
       return list.size();
    }

    public int getColumnCount() {
        return COLUMNS;
    }
    @Override
    public String getColumnName(int column) {
        switch(column) {
            case 0 : return "Purchase Code";
            case 1 : return "Supplier Name";
            case 2 : return "Purchase Date";

        }
        return null;
    }
    public Object getValueAt(int rowIndex, int columnIndex) {
        Purchase_BS pBS = list.get(rowIndex);
        switch(columnIndex) {
            case 0 : return pBS.getPCID();
            case 1 : return pBS.getSName();
            case 2 : return pBS.getPcDate();

        }
        return null;
    }

    public void addPur(List<Purchase_BS> ls)    {
        list = ls;
        this.fireTableDataChanged();
    }

    public Purchase_BS getPurchaseBS(int index) {
        return list.get(index);
    }
     public void deletePurchaser(Purchase_BS pur) {
        list.remove(pur);
        fireTableDataChanged();
    }
}
